package cn.itsource.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import cn.itsource.mapper.DriverPointMapper;
import cn.itsource.pojo.domain.DriverPoint;
import cn.itsource.pojo.ro.DriverPointRo;
import cn.itsource.result.JSONResult;
import cn.itsource.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hbase")
public class HbaseController {
    @Autowired
    private DriverPointMapper driverPointMapper;

    @GetMapping("/selectByOrderNo/{orderNo}")
    @SaIgnore
    public JSONResult selectByOrderNo(@PathVariable("orderNo")String orderNo){
        return JSONResult.success(driverPointMapper.selectByOrderNo(orderNo));
    }

    //保存司机的真实坐标
    @PostMapping("/savePoint")
    public JSONResult savePoint(@RequestBody DriverPointRo driverPointRo){

        DriverPoint driverPoint = new DriverPoint(
                IdUtil.getId(),
                driverPointRo.getLatitude(),
                driverPointRo.getLongitude(),
                StpUtil.getLoginIdAsLong(),
                driverPointRo.getOrderNo()
        );
        driverPointMapper.save(driverPoint);
        return JSONResult.success();
    }

}